import 'package:flutter/material.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({Key? key}) : super(key: key);

  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  var userName = new TextEditingController();
  var password = new TextEditingController();
  bool flag = false;
  bool flag1 = false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    this.userName.text = "张三";
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('登陆界面'),
      ),
      body: Padding(
        padding: EdgeInsets.all(10),
        child: Column(
          children: [
            TextField(
              decoration: InputDecoration(hintText: '请输入用户名'),
              controller: userName,
            ),
            TextField(
              obscureText: true,
              decoration: InputDecoration(hintText: '请输入密码'),
              controller: password,
            ),
            SizedBox(
              height: 20,
            ),
            Container(
              width: double.infinity,
              child: Checkbox(
                value: this.flag,
                onChanged: (bool? value) {
                  setState(() {
                    this.flag = value!;
                  });
                },
              ),
            ),
            SizedBox(
              height: 20,
            ),
            Container(

              child: CheckboxListTile(
                title: Text('记住密码'),
                value: this.flag1,
                onChanged: (bool? value) {
                  setState(() {
                    this.flag1 = value!;
                  });
                },
              ),
            ),
            SizedBox(
              height: 20,
            ),
            Container(
              width: double.infinity,
              child: RaisedButton(
                onPressed: () {
                  print('输入的内容：${this.userName.text}');
                },
                color: Colors.blue,
                child: Text(
                  "登陆",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
